package nowCoder;

import java.util.Scanner;

/**
 * @Auther: zzx
 * @Date: 2024.03.24/3/10
 */
public class HJ99 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 1;
        for (int i = 1; i <= n; i++) {
            int x = i * i;
            int y = i;
            while (y > 0){
                if (y % 10 != x % 10){
                    break;
                }
                y /= 10;
                x /= 10;
            }
            if (y == 0){
                System.out.println(i);
                count++;
            }
        }
        System.out.println(count);
    }
}
